package com.example.role.service.serviceimpl;

import com.example.role.mapper.RoleMapper;
import com.example.role.pojo.Role;
import com.example.role.service.IRoleService;
import com.example.role.util.ServerResponse;
import com.example.role.util.TableServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 对角色进行专门的管理
 */

@Service

public class RoleServiceImpl implements IRoleService {

    @Autowired
    RoleMapper roleMapper;
    //添加新的角色
    @Override
    public ServerResponse addroel(Role role) {
        int addroel = roleMapper.insert(role);
        if(addroel>0){
          return   ServerResponse.createSuccess("添加成功");
        }else{
           return ServerResponse.createError("添加失败");
        }

    }
//修改过往的角色
    @Override
    public ServerResponse updateRole(Role role) {

        int updateRole = roleMapper.updateByPrimaryKeySelective(role);
        if(updateRole>0){
            return ServerResponse.createSuccess("修改成功");
        }else{
            return ServerResponse.createError("修改失败");
        }
    }
//展示所有角色列表
    @Override
    public TableServerResponse queryRole(Role role) {


        return null;
    }

}
